//This is the main application class.  It extends the Application main class.

#ifndef _GAME_H_
#define _GAME_H_


#include "../Helix/Application.h"
#include "../Helix/Renderer.h"
#include "../Helix/Updater.h"
#include "../Helix/Input.h"
#include "../Helix/Domain/HelixImage.h"
#include "../Helix/View/Texture.h"
#include "../Helix/View/OpenGL/OpenGLTexture2D.h"

using namespace helix;

//Implements HRenderer and HUpdater
class Game : public Renderer, public Updater
{
private:
	static const int numPoints=2000;

	float rot[numPoints];
	float rad[numPoints];

	int findClosest(int index);
	float getX(int index);
	float getY(int index);

	OpenGLTexture2D *texturePNG;
	OpenGLTexture2D *textureTGA;
	OpenGLTexture2D *textureBMP;
public:

	Game()
	{
		for(int i=0;i<numPoints;i++){
			rot[i] = 0.0f;
			rad[i] = (float)(i) / (float)numPoints;
		}

		
		TextureParameters tParams = TextureParameters(TextureParameters::TEXTURE_2D);
		tParams.setMinFilter(TextureParameters::TRILINEAR_SAMPLE_FILTERING);
		tParams.setMaxFilter(TextureParameters::POINT_SAMPLE_FILTERING);
		tParams.setMipMapType(TextureParameters::AUTO_GENERATE_MIP_MAPS);
		tParams.setURepeat(TextureParameters::REPEAT);
		tParams.setVRepeat(TextureParameters::REPEAT);

		//First Texture
		Image *image= ImageFactory::loadImage("HelixTests\\testdata\\images\\test_32x32.png");
		texturePNG = new OpenGLTexture2D(image,&tParams);
		ImageFactory::deleteImage(image);

		//Second Texture
		image= ImageFactory::loadImage("HelixTests\\testdata\\images\\test_32x32.tga");
		textureTGA = new OpenGLTexture2D(image,&tParams);
		ImageFactory::deleteImage(image);

		//Third Texture
		image= ImageFactory::loadImage("HelixTests\\testdata\\images\\test_32x32.bmp");
		textureBMP = new OpenGLTexture2D(image,&tParams);
		ImageFactory::deleteImage(image);

	}
	~Game()
	{
		delete texturePNG;
		delete textureTGA;
		delete textureBMP;
	}

	virtual void renderScene();
	virtual void update(double dSeconds);

};

#endif
